//
// Numbers.cpp for  in /home/gomes_m//svn/google/ticket-pour-gdl/menu_V1
// 
// Made by mickael gomes
// Login   <gomes_m@epitech.net>
// 
// Started on  Wed May 29 14:02:38 2013 mickael gomes
// Last update Thu May 30 14:10:17 2013 mickael gomes
//

#include		"Numbers.hh"

Numbers::Numbers()
{
  char			min = 'a';
  char			maj = 'A';
  char			num = '0';
  float			x = 0.0011;
  float			add = 0.0037;

  ftab_[0] = &Numbers::minusOne;
  ftab_[1] = &Numbers::plusOne;
  while (maj <= 'Z')
    {
      tab_.push_back(std::pair <char, float>(maj++, x));
      x += add;
    }
  while (min <= 'z')
    {
      tab_.push_back(std::pair <char, float>(min++, x));
      x += add;
    }
  while (num <= ':')
    {
      tab_.push_back(std::pair <char, float>(num++, x));
      x += add;
    }
  it_ = tab_.begin();
  vertexX1_ = it_->second;
  setVertex();
}

Numbers::~Numbers()
{

}

void		        Numbers::update(Key key, Cursor &cursor)
{
  line_ = cursor.coord.moveY_ / -cursor.coord.moveYValue_;
  (this->*ftab_[key - 3])();
  std::cout << "couilles" << std::endl; 
  setVertex();
  std::cout << vertexX1_ << " ; " << vertexY1_ << " ; " << vertexX2_ << " ; " << vertexY2_ << std::endl;
  usleep(100000);
}

void			Numbers::plusOne()
{
  if (it_ + 1 == tab_.end())
    it_ = tab_.begin();
  else
    it_++;
  std::cout << it_->first << std::endl;
  vertexX1_ = it_->second;
}

void			Numbers::minusOne()
{
  if (it_ == tab_.begin())
    {
      it_ = tab_.end();
      it_--;
    }
  else
    it_--;
  std::cout << it_->first << std::endl;
  vertexX1_ = it_->second;
}

void			Numbers::setVertex()
{
  vertexX2_ = vertexX1_ + 0.005;
  vertexY1_ = 0.049;
  vertexY2_ = 0.066;
}
